//
// Created by liushuai on 18-8-9.
//

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int gcd(int &num,int &den)
{
    if(num<den)
    {
        throw "第一个参数必须比第二个大";
        return -1;
    }
    else
    {
        while(num%den!=0)
        {
            int temp;
            temp = num%den;
            num = den;
            den = temp;
        }
        return den;
    }

}
int main() {
    int num, den;
    int flag = -1;
    int r;
    cout << "输入两个数： " << endl;

    while(cin>>num>>den)
    {
        try {
            int r = gcd(num,den);
            cout<<"公约数为: "<<r;
        }
        catch(const char *s)
        {
            cout<<s<<" ";
            continue;
        }

    }

}